<?php
  namespace Home\Controller;
   use Think\Controller;
   class   QuController extends Controller {
		public function index(){
		
      $page = isset($_GET['page'])?intval($_GET['page']):1;
      $each_page =30; 
      
      $Data= M('goods');// 实例化Data数据模型
      $total = $Data->count();
      
     $total_page =ceil($total/$each_page);  
     $this->assign('total_page',$total_page); //总页数
       
	   $page = ($page<0)?1:$page;
	   $page = ($page>$total_page)?$total_page:$page;
	  
	   
	   $offset = ($page-1)*$each_page;
     $result= $Data->where('type=4')->order('date desc')->limit($offset ,$each_page)->select();   
     
      $this->assign('total',$total );//留言总数
      $this->assign('page',$page);
     $this->assign('data',$result); 
     
     
     //$dat= M('goods');
     //$res= $dat->order('postdtm desc')->limit(0,10)->select();  
    // $this->assign('res',$res);  
     $this->display();  
		}
		
		public function down(){
    
               if(IS_POST)
     {        
            
                $m=M('goods');
                $data['id']=$_POST['id'];
                //$this->success('数据修改成功','index');
                $data['url']=$_POST['url'];
                $data['name']=$_POST['name'];
                $count=$m->save($data);
                if($count>0){
                  $this->ajaxReturn("修改数据成功 !",'eval');
                  }else{
                  $this->ajaxReturn("修改失败！",'eval');
             }
      } elseif(IS_GET){
        $m=M('goods');
        $id['id']=$_GET['id'];
        $data=$m->where($id)->select(); 
        $this->assign('dat',$data);//留言总数
        $this->display();
     }
      else{
      
        $this->error('非法操作哦！');
      }
   }         
		
}
?>